//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#ifndef __CCONSOLEFILE_H__
#define __CCONSOLEFILE_H__

#include <elapi.h>
#include <stdlib.h>

class CConsoleFile : public IAbsoluteIO, public IBasicFile
{
public:
    CARAPI_(PInterface) Probe(REIID riid);

    CARAPI_(UInt32) AddRef();

    CARAPI_(UInt32) Release();

    CARAPI Aggregate(
        /* [in] */ AggregateType type,
        /* [in] */ IInterface *pObj);

    CARAPI GetDomain(
        /* [out] */ IInterface **ppObj);

    CARAPI Read(
        /* [in] */ Int32  offset,
        /* [in] */ Int32  toRead,
        /* [out] */ MemoryBuf * ezbBuf);

    CARAPI Write(
        /* [in] */ Int32  offset,
        /* [in] */ const MemoryBuf & ezbBuf,
        /* [out] */ Int32  * pWrite);

    CARAPI Sync();

    CARAPI GetOptimalBlockSize(
        /* [out] */ Int32 * pSize);

    CARAPI GetType(
        /* [out] */ FileType *pType);

    CARAPI GetAccessTime(
        /* [out] */ Int32 * pTime);

    CARAPI SetAccessTime(
        /* [in] */ Int32 time);

    CARAPI GetModificationTime(
        /* [out] */ Int32 * pTime);

    CARAPI SetModificationTime(
        /* [in] */ Int32 time);

    CARAPI GetCreateTime(
        /* [out] */ Int32 * pTime);

    CARAPI CheckAccessMode(
        /* [in] */ FileAccessMode mode);

    CARAPI GetAccessMode(
        /* [out] */ FileAccessMode * pMode);

    CARAPI SetAccessMode(
        /* [in] */ FileAccessMode mode);

    CARAPI GetShareMode(
        /* [out] */ FileShareMode *pMode);

    CARAPI SetShareMode(
        /* [in] */ FileShareMode mode);

    CARAPI GetSize(
        /* [out] */ Int32 * pSize);

    CARAPI SetSize(
        /* [in] */ Int32 size);

public://method
    CConsoleFile();

#if defined(_win32) || defined(_wince) || defined(_linux)
    CConsoleFile(int fd);
#endif

    virtual ~CConsoleFile();

private://data
#if defined(_win32) || defined(_wince) || defined(_linux)
    int m_ifd;
#endif
    Interlocked m_RefCnt;
};

#endif // __CCONSOLEFILE_H__
